<#include "/common/head.ftl">

<#macro formatOn status>
	<#if status == 22>
		;background-color:yellow
	<#elseif status == 1>
		;background-color:green
	<#elseif status == 2>
		;background-color:lightgray
	</#if>
</#macro>

<div style="overflow:auto">

<style>
	#div_odd * {color:#696969}
</style>

<table border="1" cellspacing="0" cellpadding=0" style="width:160%">
	<tr style="text-align:center; font-weight:bold; background-color:#04aa9c; color:#FFF; font-size: 11px; padding:2px">
		<td rowspan="2" style="text-align:center; width:20px">${i18n.getMessage('ordinalNumber')}</td>
		<td rowspan="2" style="text-align:center">${i18n.getMessage('class')}</td>
		<td rowspan="2">${i18n.getMessage('time')}</td>
		<td rowspan="2">${i18n.getMessage('startDate')}</td>
		<td rowspan="2">${i18n.getMessage('endDate')}</td>
		<td rowspan="2">Midterm <br/> Written</td>
		<td rowspan="2">Final <br/> Spoken</td>
		<td rowspan="2">Final <br/> Written</td>
		<td rowspan="2">Sample <br/> Test</td>
		<td rowspan="2">Cambridge <br/> Test</td>
		<td rowspan="2">Room <br/> (Anna)</td>
		<td rowspan="2">Number of <br/> Students</td>
		<#list days as day>
			<td style="width:50px;height:20px">${day?string('EEE')}</td>
		</#list>
	</tr>
	<tr style="text-align:center;font-weight:bold;background-color:#04aa9c;color:#FFF;font-size:11px;padding:2px">
		<#list days as day>
			<td>${day?string('dd-MMM')}</td>
		</#list>
	</tr>
	<#assign hashmap = {}>
	<#list offerings as offering>
		<tr <#if ((offering_index % 2) = 0)>style="background-color:#DEDEDE"<#else>style="background-color:#FFF"</#if>>
			<td style="text-align:center;border: solid 1px #FFF; padding-left:3px">${(offering_index + 1)!}</td>
			<td style="text-align:center;border: solid 1px #FFF; padding-left:3px"><a href="#" onclick="cc('offering/showInfoOffering.sgt?id=${offering.id}')"><span <#if offering.isStarted(fromDateDate, toDateDate)> style="background-color:yellow" </#if> <#if offering.isFinished(fromDateDate, toDateDate)> style="color:white;background-color:red" </#if>>${(offering.name)!}</span></a></td>
			<td style="text-align:center;width:100px;border: solid 1px #FFF; padding-left:3px">${(offering.shift.startTime)!} - ${(offering.shift.endTime)!}</td>
			<td style="text-align:center;width:80px;border: solid 1px #FFF; padding-left:3px">${(offering.startDate?date)!}</td>
			<td style="text-align:center;width:80px;border: solid 1px #FFF; padding-left:3px">${(offering.endDate?date)!}</td>
			<td style="text-align:center;width:60px;border: solid 1px #FFF; padding-left:3px;<#if action.isBetween(offering.midtermWrittenDate)>background-color:#00BFFF</#if>">${(offering.midtermWrittenDate?string('dd-MMM'))!}</td>
			<td style="text-align:center;width:60px;border: solid 1px #FFF; padding-left:3px;<#if action.isBetween(offering.finalSpokenDate)>background-color:#00BFFF</#if>">${(offering.finalSpokenDate?string('dd-MMM'))!}</td>
			<td style="text-align:center;width:60px;border: solid 1px #FFF; padding-left:3px;<#if action.isBetween(offering.finalWrittenDate)>background-color:#00BFFF</#if>">${(offering.finalWrittenDate?string('dd-MMM'))!}</td>
			<td style="text-align:center;width:60px;border: solid 1px #FFF; padding-left:3px;<#if action.isBetween(offering.cambridgeSpokenDate)>background-color:#00BFFF</#if>">${(offering.cambridgeSpokenDate?string('dd-MMM'))!}</td>
			<td style="text-align:center;width:60px;border: solid 1px #FFF; padding-left:3px;<#if action.isBetween(offering.cambridgeWrittenDate)>background-color:#00BFFF</#if>">${(offering.cambridgeWrittenDate?string('dd-MMM'))!}</td>
			<td style="text-align:center;width:50px;border: solid 1px #FFF; padding-left:3px">${(offering.room.name)!}</td>
			<td style="text-align:center;width:50px;border: solid 1px #FFF; padding-left:3px">${(offering.getNumberOfActiveStudents(toDateDate))!}</td>
			<#list days as day>
					<#assign teacher = (offering.getTeacher(day))! >
					<#assign makeUp = (offering.getInstructorMakeUp(day))!>
					<#assign interruption = (offering.getInstructorInterruption(day))!>
						<#if makeUp?has_content>
							<#assign status = 22>
						<#elseif interruption?has_content>
							<#assign status = (interruption.getStatus(day))!(-1)>
						<#else>					
							<#assign status = 0>
						</#if>
					<#assign abs = offering.getNumberOfAbsentMembers(day)>
					<td style="text-align:center;width:100px;border: solid 1px #FFF; padding-left:3px">
						<div <#if day_index%2 == 0>id="div_odd"</#if>>
						<#if !action.isValid(day, offering.startDate, offering.endDate)>
							&nbsp;fgfgfg
						<#elseif teacher?has_content && DayOffService.exists(day)>
							<span style="color:red">Holiday</span>
						<#elseif status == 0>
							<a href="#" onclick="cc('offering/showAddTeachingInterruption.sgt?teacherId=${(teacher.id)!}&offeringId=${(offering.id)!}&fromDate=${day?date}')" title="${(teacher.fullName)!}">${(teacher.midName)!} ${(teacher.firstName)!}</a>
						<#elseif status == 1>
							<a href="#" onclick="cc('offering/showEditTeachingInterruption.sgt?id=${(interruption.id)!}')" style="font-weight:bold" title="${(interruption.substituteTeacher.fullName)!}">${(interruption.substituteTeacher.midName)!} ${(interruption.substituteTeacher.firstName)!}</a>
						<#elseif status == 11>
							<a href="#" onclick="cc('offering/showEditTeachingInterruption.sgt?id=${(interruption.id)!}')" title="${(interruption.substituteTeacher.fullName)!}">${(interruption.substituteTeacher.midName)!} ${(interruption.substituteTeacher.firstName)!}</a>
						<#elseif status == 2>
							<a href="#" onclick="cc('offering/showEditTeachingInterruption.sgt?id=${(interruption.id)!}')" style="font-weight:bold" title="${(teacher.fullName)!}"><span style="text-decoration: line-through">${(teacher.midName)!} ${(teacher.firstName)!}</span></a>
						<#elseif status == 22>
							<a href="#" onclick="cc('offering/showEditTeachingInterruption.sgt?id=${(makeUp.id)!}')" style="font-weight:bold;color:orange" title="${(teacher.fullName)!}">${(teacher.midName)!} ${(teacher.firstName)!}</a>
						<#else>
							&nbsp;
						</#if>
						<#if (abs != 0)>
							<a href="#" onclick="cc('offering/showInfoAttendance.sgt?offeringId=${offering.id}')">[${abs}]</a>
						</#if>
						</div>
					</td>
			</#list>
		</tr>
	</#list>
</table>

</div>

<br/>

* <span style="background-color:yellow">Yellow color</span> is for starting classes, 
  <span style="background-color:red;color:white">red color</span> is for ending classes, 
  <span style="background-color:#00BFFF;color:black">blue color</span> is for exam dates